#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/10/29 21:33
# @Author  : summer
# @Email   : 610658552@qq.com
# @File    : filter_sms_provider.py
# @Software: PyCharm
# @Desc    : SMSProvider过滤器
import django_filters
from ssms.models import SMSProvider


class SMSProviderFilter(django_filters.FilterSet):
    """SMSProvider过滤器：支持多条件筛选"""
    # 按供应商名称模糊搜索
    sms_name = django_filters.CharFilter(field_name='sms_name', lookup_expr='icontains')
    # 按状态筛选（是否启用）
    is_active = django_filters.NumberFilter(field_name='is_active')
    # 按创建时间范围筛选
    create_time_start = django_filters.DateTimeFilter(field_name='create_time', lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name='create_time', lookup_expr='lte')

    class Meta:
        model = SMSProvider
        fields = ['sms_name', 'is_active', 'create_time_start', 'create_time_end']